package main.Q2601_2700;

import java.util.Stack;

public class Q2691_2700 {
	public static void main(String[] args) {
		System.out.println("Question2691：");
		System.out.println("Question2692：");
		System.out.println("Question2693：");
		System.out.println("Question2694：");
		System.out.println("Question2695：");
		System.out.println("Question2696：删除子串后的字符串最小长度");
		System.out.println("Question2697：");
		System.out.println("Question2698：");
		System.out.println("Question2699：");
		System.out.println("Question2700：");
	}
}

class Question2696 {
	public int minLength(String s) {
		Stack<Character> stack = new Stack<>();
		for (int i = 0; i < s.length(); i++) {
			if (stack.isEmpty()) {
				stack.push(s.charAt(i));
			} else if (stack.peek() == 'A' && s.charAt(i) == 'B') {
				stack.pop();
			} else if (stack.peek() == 'C' && s.charAt(i) == 'D') {
				stack.pop();
			} else {
				stack.push(s.charAt(i));
			}
		}
		return stack.size();
	}
}